package com.ailiwu.www.ailiwu.Fragment;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.ailiwu.www.ailiwu.R;
import com.ailiwu.www.ailiwu.base.BaseFragment;

/**
 * Author:    Yyang
 * Version    V1.0
 * Date:      ${date}  ${time}.
 * Description: 图文介绍页面
 * Modification  History:
 * Date         	Author        		Version        	Description
 * -----------------------------------------------------------------------------------
 * ${date}          Yyang                1.0                1.0
 * Why & What is modified:
 */
public class IntroduceFragment extends BaseFragment {
    private String detail_html;
    private WebView wv_instrodyce;
    private RecyclerView recyView_instroduce;
    private int id;

    @Override
    protected View inflateView() {
        return View.inflate(getActivity(), R.layout.fragment_introduce, null);
    }

    public static IntroduceFragment newInstance(String detail_html) {
        IntroduceFragment fragment = new IntroduceFragment();
        Bundle args = new Bundle();
        args.putString("DETAIL_HTML", detail_html);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            detail_html = getArguments().getString("DETAIL_HTML");
            id = getArguments().getInt("ID");
            Log.i("oye", id + "");
        }
    }

    @Override
    protected void initView(View view) {
        wv_instrodyce = (WebView) view.findViewById(R.id.wv_instroduce);
        WebSettings webSettings = wv_instrodyce.getSettings();
        webSettings.setDefaultTextEncodingName("UTF-8");
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDisplayZoomControls(true);
        webSettings.setSupportZoom(true);
        // 设置缩放工具的显示
        webSettings.setBuiltInZoomControls(true);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    }

    @Override
    protected void initData() {
//        wv_instrodyce.loadData(detail_html, "text/html", "UTF-8");
        wv_instrodyce.loadDataWithBaseURL(null,detail_html,"text/html","UTF-8",null);
    }

}
